<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>这是一个页面</title>
    <link rel="stylesheet" href="./css/index.css">
    <script src="https://s3.pstatp.com/cdn/expire-1-M/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
    <div id="box">
         <form>
             <input type="text" name="user" value="">
             <input type="password" name="password">
             <button type="button" id="buton">提交</button>
         </form>
    </div>
</body>
<script>
    $(function (){
        $('#buton').click(function (){
            var name = $('input[name="user"]').val();
            var password = $('input[name="password"]').val();
            if(name==""||password==""){
                alert("内容不能为空")
                return  false;
            }
           $.ajax({
               url:"http://localhost/test1.php",
               type:"post",
               data:{name:name,pass:password},
               dataType:"json",
               success:function (res){
                 if(res.status==200){
                     alert(res.msg);
                 }else {
                     alert(res.msg);
                 }
               },
               error:function (){
                   alert("请求失败")
               }
           })
        })
    })
</script>
</html>